package org.gnut.tinyurl.portal.jetspeed;

import javax.portlet.PortletRequest;
import javax.servlet.http.HttpServletRequest;

import org.gnut.tinyurl.portlet.servlet.RemoteProvider;
import org.apache.jetspeed.request.RequestContext;

public class RemoteProvicderImpl implements RemoteProvider {
	protected PortletRequest portletRequest;
	protected HttpServletRequest httpServletRequest;

	public void setPortletRequest(PortletRequest portletRequest) {
		this.portletRequest = portletRequest;

	}

	public String getRemoteAddr() {
		RequestContext rc = (RequestContext) portletRequest
				.getAttribute(RequestContext.REQUEST_PORTALENV);
		String remoteAddr = rc.getRequest().getRemoteAddr();
		System.out.println("=====================================================");
		System.out.println("remoteAddr :"+remoteAddr);
		System.out.println("=====================================================");
		return remoteAddr;
	}

	public String getRemoteHost() {
		RequestContext rc = (RequestContext) portletRequest
				.getAttribute(RequestContext.REQUEST_PORTALENV);
		return rc.getRequest().getRemoteHost();
	}

	public int getRemotePort() {
		RequestContext rc = (RequestContext) portletRequest
				.getAttribute(RequestContext.REQUEST_PORTALENV);
		return rc.getRequest().getRemotePort();
	}

	public void setHttpServletRequest(HttpServletRequest httpServletRequest) {
		this.httpServletRequest = httpServletRequest;
	}

}
